﻿using System;
using System.Globalization;
using Loki.Commands;

namespace Loki.UI.Win.Test
{
    public class CommandToGlyphConverter : IValueConverter
    {
        #region IValueConverter Membres

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var command = value as ICommand;
            if (value == null)
            {
                return null;
            }
            else
            {
                bool active = (bool)parameter;

                if (command == ApplicationCommands.Save)
                {
                    return active ? Properties.Resources.mni_save : Properties.Resources.mni_save_disabled;
                }

                if (command == ApplicationCommands.Refresh)
                {
                    return active ? Properties.Resources.mni_refresh : Properties.Resources.mni_refresh_disabled;
                }

                if (command == ApplicationCommands.Export)
                {
                    return active ? Properties.Resources.mni_excel : Properties.Resources.mni_excel_disabled;
                }

                if (command == ApplicationCommands.Search)
                {
                    return active ? Properties.Resources.mni_view : Properties.Resources.mni_view_disabled;
                }

                return null;
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotSupportedException();
        }

        #endregion IValueConverter Membres
    }
}